package com.pureut.quality.controller;


import com.pureut.common.core.web.controller.BaseController;
import com.pureut.common.core.web.domain.AjaxResult;
import com.pureut.common.core.web.page.TableDataInfo;
import com.pureut.common.log.annotation.Log;
import com.pureut.common.log.enums.BusinessType;
import com.pureut.quality.domain.dto.EportCorrectionNoticeDto;
import com.pureut.quality.domain.dto.ExternalAuditPlanDto;
import com.pureut.quality.domain.vo.EportCorrectionNoticeVo;
import com.pureut.quality.domain.vo.ExternalAuditPlanVo;
import com.pureut.quality.domain.vo.SubmitVo;
import com.pureut.quality.service.EportCorrectionNoticeService;
import com.pureut.quality.service.ExternalAuditPlanService;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @ClassDescription: 外审报告及整改通知
 * @Author: YSL
 * @Created: 2025/4/8 10:19
 */
@RestController
@RequestMapping("/eportCorrectionNotice")
public class EportCorrectionNoticeController extends BaseController {

    /**
     * 外审报告及整改通知实现层
     */
    @Resource
    EportCorrectionNoticeService eportCorrectionNoticeService;

    /**
     * 外审报告及整改通知列表
     */
//    @RequiresPermissions("quality:verifyconfig:badcategory:list")
    @GetMapping("/list")
    public TableDataInfo list(EportCorrectionNoticeVo eportCorrectionNoticeVo)
    {
        startPage();
        List<EportCorrectionNoticeDto> list = eportCorrectionNoticeService.listEportCorrectionNotice(eportCorrectionNoticeVo);
        return getDataTable(list);
    }

    /**
     * 根据id获取详细信息
     */
//    @RequiresPermissions("quality:verifyconfig:badcategory:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable Long id)
    {
        return AjaxResult.success(eportCorrectionNoticeService.getInfo(id));
    }

    /**
     * 外审报告及整改通知新增
     */
//    @RequiresPermissions("quality:verifyconfig:badcategory:add")
    @Log(title = "外审报告及整改通知新增", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@Validated @RequestBody EportCorrectionNoticeVo eportCorrectionNoticeVo) throws Exception {
        return toAjax(eportCorrectionNoticeService.insertEportCorrectionNotice(eportCorrectionNoticeVo));
    }

    /**
     * 外审报告及整改通知修改
     */
//    @RequiresPermissions("quality:verifyconfig:badcategory:add")
    @Log(title = "外审报告及整改通知修改", businessType = BusinessType.INSERT)
    @PutMapping
    public AjaxResult edit(@Validated @RequestBody EportCorrectionNoticeVo eportCorrectionNoticeVo) throws Exception {
        return toAjax(eportCorrectionNoticeService.updateEportCorrectionNotice(eportCorrectionNoticeVo));
    }

    /**
     * 外审报告及整改通知删除
     */
//    @RequiresPermissions("quality:verifyconfig:badcategory:remove")
    @Log(title = "外审报告及整改通知删除", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable("ids") String ids){
        return toAjax(eportCorrectionNoticeService.removeEportCorrectionNotice(ids));
    }

}
